using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Runtime.InteropServices;
using PickGold.Charting;
using PickGold.Charting.Utilities;

namespace PickGold.Charting.ChartTypes
{
	internal class StackedAreaChart : AreaChart
	{
		protected GraphicsPath areaBottomPath = new GraphicsPath();
		protected bool hundredPercentStacked;
		protected double prevNegY = double.NaN;
		protected double prevPositionX = double.NaN;
		protected double prevPosY = double.NaN;

		public StackedAreaChart()
		{
			base.multiSeries = true;
			base.COPCoordinatesToCheck = COPCoordinates.Y | COPCoordinates.X;
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && (this.areaBottomPath != null))
			{
				this.areaBottomPath.Dispose();
				this.areaBottomPath = null;
			}
			base.Dispose(disposing);
		}

		protected override GraphicsPath Draw3DSurface(ChartArea area, ChartGraphics graph, Matrix3D matrix, LightStyle lightStyle, DataPoint3D prevDataPointEx, float positionZ, float depth, ArrayList points, int pointIndex, int pointLoopIndex, float tension, DrawingOperationTypes operationType, float topDarkening, float bottomDarkening, PointF thirdPointPosition, PointF fourthPointPosition, bool clippedSegment)
		{
			if (pointLoopIndex != 2)
			{
				return base.Draw3DSurface(area, graph, matrix, lightStyle, prevDataPointEx, positionZ, depth, points, pointIndex, pointLoopIndex, tension, operationType, topDarkening, bottomDarkening, thirdPointPosition, fourthPointPosition, clippedSegment);
			}
			DataPoint3D neighborDataPoint = (DataPoint3D)points[pointIndex];
			if (neighborDataPoint.index == 2)
			{
				int neighborPointIndex = 0;
				DataPoint3D pointEx = ChartGraphics.FindPointByIndex(points, neighborDataPoint.index - 1, neighborDataPoint, ref neighborPointIndex);
				this.DrawLabels3D(area, graph, area.Common, pointEx, positionZ, depth);
			}
			this.DrawLabels3D(area, graph, area.Common, neighborDataPoint, positionZ, depth);
			return new GraphicsPath();
		}

		private void DrawLabels3D(ChartArea area, ChartGraphics graph, CommonElements common, DataPoint3D pointEx, float positionZ, float depth)
		{
			string label = pointEx.dataPoint.Label;
			bool isValueShownAsLabel = pointEx.dataPoint.IsValueShownAsLabel;
			if ((!pointEx.dataPoint.IsEmpty && ((pointEx.dataPoint.series.IsValueShownAsLabel || isValueShownAsLabel) || (label.Length > 0))) || (isValueShownAsLabel || (label.Length > 0)))
			{
				using (StringFormat format = new StringFormat())
				{
					string str2;
					format.Alignment = StringAlignment.Center;
					format.LineAlignment = StringAlignment.Center;
					if (label.Length == 0)
					{
						double num = pointEx.dataPoint.YValues[(base.labelYValueIndex == -1) ? base.YValueIndex : base.labelYValueIndex];
						if (this.hundredPercentStacked && (pointEx.dataPoint.LabelFormat.Length == 0))
						{
							num = Math.Round(num, 2);
						}
						str2 = ValueConverter.FormatValue(pointEx.dataPoint.series.Chart, pointEx.dataPoint, pointEx.dataPoint.Tag, num, pointEx.dataPoint.LabelFormat, pointEx.dataPoint.series.YValueType, ChartElementType.DataPoint);
					}
					else
					{
						str2 = pointEx.dataPoint.ReplaceKeywords(label);
					}
					Point3D[] points = new Point3D[] { new Point3D((float)pointEx.xPosition, ((float)(pointEx.yPosition + pointEx.height)) / 2f, positionZ + depth) };
					area.matrix3D.TransformPoints(points);
					SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(str2, pointEx.dataPoint.Font, new SizeF(1000f, 1000f), StringFormat.GenericTypographic));
					RectangleF empty = RectangleF.Empty;
					SizeF ef3 = new SizeF(relativeSize.Width, relativeSize.Height);
					ef3.Height += relativeSize.Height / 8f;
					ef3.Width += ef3.Width / ((float)str2.Length);
					empty = new RectangleF(points[0].PointF.X - (ef3.Width / 2f), (points[0].PointF.Y - (ef3.Height / 2f)) - (relativeSize.Height / 10f), ef3.Width, ef3.Height);
					using (Brush brush = new SolidBrush(pointEx.dataPoint.LabelForeColor))
					{
						graph.DrawPointLabelStringRel(common, str2, pointEx.dataPoint.Font, brush, points[0].PointF, format, pointEx.dataPoint.LabelAngle, empty, pointEx.dataPoint.LabelBackColor, pointEx.dataPoint.LabelBorderColor, pointEx.dataPoint.LabelBorderWidth, pointEx.dataPoint.LabelBorderDashStyle, pointEx.dataPoint.series, pointEx.dataPoint, pointEx.index - 1);
					}
				}
			}
		}

		protected override void GetBottomPointsPosition(CommonElements common, ChartArea area, float axisPosition, ref DataPoint3D firstPoint, ref DataPoint3D secondPoint, PointF thirdPointPosition, PointF fourthPointPosition, out PointF thirdPoint, out PointF fourthPoint)
		{
			Axis axis = area.GetAxis(AxisName.Y, firstPoint.dataPoint.series.YAxisType, firstPoint.dataPoint.series.YSubAxisName);
			Axis axis2 = area.GetAxis(AxisName.X, firstPoint.dataPoint.series.XAxisType, firstPoint.dataPoint.series.XSubAxisName);
			double position = this.GetYValue(area.Common, area, firstPoint.dataPoint.series, firstPoint.dataPoint, firstPoint.index - 1, 0);
			double xPosition = (float)firstPoint.xPosition;
			if (position >= 0.0)
			{
				if (double.IsNaN(this.prevPosY))
				{
					position = axisPosition;
				}
				else
				{
					position = axis.GetPosition(this.prevPosY);
					xPosition = axis2.GetPosition(this.prevPositionX);
				}
			}
			else if (double.IsNaN(this.prevNegY))
			{
				position = axisPosition;
			}
			else
			{
				position = axis.GetPosition(this.prevNegY);
				xPosition = axis2.GetPosition(this.prevPositionX);
			}
			thirdPoint = new PointF((float)xPosition, (float)position);
			position = this.GetYValue(area.Common, area, secondPoint.dataPoint.series, secondPoint.dataPoint, secondPoint.index - 1, 0);
			xPosition = (float)secondPoint.xPosition;
			if (position >= 0.0)
			{
				if (double.IsNaN(this.prevPosY))
				{
					position = axisPosition;
				}
				else
				{
					position = axis.GetPosition(this.prevPosY);
					xPosition = axis2.GetPosition(this.prevPositionX);
				}
			}
			else if (double.IsNaN(this.prevNegY))
			{
				position = axisPosition;
			}
			else
			{
				position = axis.GetPosition(this.prevNegY);
				xPosition = axis2.GetPosition(this.prevPositionX);
			}
			fourthPoint = new PointF((float)xPosition, (float)position);
			if (!float.IsNaN(thirdPointPosition.X))
			{
				thirdPoint.X = (firstPoint.xCenterVal == 0.0) ? ((float)firstPoint.xPosition) : ((float)firstPoint.xCenterVal);
				thirdPoint.Y = (((thirdPointPosition.X - fourthPoint.X) / (thirdPoint.X - fourthPoint.X)) * (thirdPoint.Y - fourthPoint.Y)) + fourthPoint.Y;
				thirdPoint.X = thirdPointPosition.X;
			}
			if (!float.IsNaN(thirdPointPosition.Y))
			{
				thirdPoint.Y = thirdPointPosition.Y;
			}
			if (!float.IsNaN(fourthPointPosition.X))
			{
				fourthPoint.X = (secondPoint.xCenterVal == 0.0) ? ((float)secondPoint.xPosition) : ((float)secondPoint.xCenterVal);
				fourthPoint.Y = (((fourthPointPosition.X - fourthPoint.X) / (thirdPoint.X - fourthPoint.X)) * (thirdPoint.Y - fourthPoint.Y)) + fourthPoint.Y;
				fourthPoint.X = fourthPointPosition.X;
			}
			if (!float.IsNaN(fourthPointPosition.Y))
			{
				fourthPoint.Y = fourthPointPosition.Y;
			}
		}

		protected override float GetDefaultTension()
		{
			return 0f;
		}

		public override Image GetImage(ChartTypeRegistry registry)
		{
			return (Image)registry.ResourceManager.GetObject(this.Name + "ChartType");
		}

		protected override int GetPointLoopNumber(bool selection, ArrayList pointsArray)
		{
			if (selection)
			{
				return 1;
			}
			int num = 1;
			foreach (object obj2 in pointsArray)
			{
				DataPoint3D pointd = (DataPoint3D)obj2;
				if (pointd.dataPoint.Color.A != 0xff)
				{
					num = 2;
				}
				if ((pointd.dataPoint.Label.Length > 0) || pointd.dataPoint.series.IsValueShownAsLabel)
				{
					return 3;
				}
			}
			return num;
		}

		protected override void GetTopSurfaceVisibility(ChartArea area, DataPoint3D firstPoint, DataPoint3D secondPoint, bool upSideDown, float positionZ, float depth, Matrix3D matrix, ref SurfaceNames visibleSurfaces)
		{
			base.GetTopSurfaceVisibility(area, firstPoint, secondPoint, upSideDown, positionZ, depth, matrix, ref visibleSurfaces);
			if ((visibleSurfaces & SurfaceNames.Top) == SurfaceNames.Top)
			{
				bool flag = false;
				foreach (Series series in area.Common.DataManager.Series)
				{
					if (string.Compare(series.ChartTypeName, secondPoint.dataPoint.series.ChartTypeName, true, CultureInfo.CurrentCulture) != 0)
					{
						continue;
					}
					if (flag)
					{
						DataPointCustomProperties emptyPointStyle = series.Points[secondPoint.index - 1];
						if (series.Points[secondPoint.index - 1].IsEmpty)
						{
							emptyPointStyle = series.EmptyPointStyle;
						}
						if (emptyPointStyle.Color.A == 0xff)
						{
							visibleSurfaces ^= SurfaceNames.Top;
						}
						break;
					}
					if (string.Compare(series.Name, secondPoint.dataPoint.series.Name, StringComparison.Ordinal) == 0)
					{
						flag = true;
					}
				}
			}
			if ((visibleSurfaces & SurfaceNames.Bottom) != SurfaceNames.Bottom)
			{
				DataPointCustomProperties properties2 = null;
				foreach (Series series2 in area.Common.DataManager.Series)
				{
					if (string.Compare(series2.ChartTypeName, secondPoint.dataPoint.series.ChartTypeName, StringComparison.OrdinalIgnoreCase) == 0)
					{
						if ((properties2 != null) && (string.Compare(series2.Name, secondPoint.dataPoint.series.Name, StringComparison.Ordinal) == 0))
						{
							if (properties2.Color.A != 0xff)
							{
								visibleSurfaces |= SurfaceNames.Bottom;
							}
							break;
						}
						properties2 = series2.Points[secondPoint.index - 1];
						if (series2.Points[secondPoint.index - 1].IsEmpty)
						{
							properties2 = series2.EmptyPointStyle;
						}
					}
				}
			}
		}

		public override double GetYValue(CommonElements common, ChartArea area, Series series, DataPoint point, int pointIndex, int yValueIndex)
		{
			double naN = double.NaN;
			if (!area.Area3DStyle.Enable3D)
			{
				return point.YValues[0];
			}
			if (yValueIndex == -1)
			{
				double crossing = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName).Crossing;
				naN = this.GetYValue(common, area, series, point, pointIndex, 0);
				if (area.Area3DStyle.Enable3D && (naN < 0.0))
				{
					naN = -naN;
				}
				if (naN >= 0.0)
				{
					if (!double.IsNaN(this.prevPosY))
					{
						crossing = this.prevPosY;
					}
				}
				else if (!double.IsNaN(this.prevNegY))
				{
					crossing = this.prevNegY;
				}
				return (naN - crossing);
			}
			this.prevPosY = double.NaN;
			this.prevNegY = double.NaN;
			this.prevPositionX = double.NaN;
			foreach (Series series2 in common.DataManager.Series)
			{
				if (((string.Compare(series.ChartArea, series2.ChartArea, StringComparison.Ordinal) != 0) || (string.Compare(series.ChartTypeName, series2.ChartTypeName, StringComparison.OrdinalIgnoreCase) != 0)) || !series2.IsVisible())
				{
					continue;
				}
				naN = series2.Points[pointIndex].YValues[0];
				if (area.Area3DStyle.Enable3D && (naN < 0.0))
				{
					naN = -naN;
				}
				if (!double.IsNaN(naN))
				{
					if ((naN >= 0.0) && !double.IsNaN(this.prevPosY))
					{
						naN += this.prevPosY;
					}
					if ((naN < 0.0) && !double.IsNaN(this.prevNegY))
					{
						naN += this.prevNegY;
					}
				}
				if (string.Compare(series.Name, series2.Name, StringComparison.Ordinal) == 0)
				{
					return naN;
				}
				if (naN >= 0.0)
				{
					this.prevPosY = naN;
				}
				if (naN < 0.0)
				{
					this.prevNegY = naN;
				}
				this.prevPositionX = series2.Points[pointIndex].XValue;
				if ((this.prevPositionX == 0.0) && ChartHelper.IndexedSeries(series))
				{
					this.prevPositionX = pointIndex + 1;
				}
			}
			return naN;
		}

		public override void Paint(ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
		{
			base.Common = common;
			graph.SetClip(area.PlotAreaPosition.ToRectangleF());
			this.ProcessChartType(false, graph, common, area, seriesToDraw);
			graph.ResetClip();
		}

		protected override void ProcessChartType(bool selection, ChartGraphics graph, CommonElements common, ChartArea area, Series seriesToDraw)
		{
			base.Common = common;
			ArrayList list = null;
			ArrayList list2 = null;
			if (area.Area3DStyle.Enable3D)
			{
				base.ProcessChartType(selection, graph, common, area, seriesToDraw);
			}
			else
			{
				bool flag = ChartHelper.IndexedSeries(base.Common, area.GetSeriesFromChartType(this.Name).ToArray());
				bool flag2 = false;
				bool flag3 = false;
				int count = -1;
				foreach (Series series in common.DataManager.Series)
				{
					if (((string.Compare(series.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) != 0) || (series.ChartArea != area.Name)) || !series.IsVisible())
					{
						continue;
					}
					if (base.areaPath != null)
					{
						base.areaPath.Dispose();
						base.areaPath = null;
					}
					this.areaBottomPath.Reset();
					if (count == -1)
					{
						count = series.Points.Count;
					}
					else if (count != series.Points.Count)
					{
						throw new ArgumentException(SR.ExceptionStackedAreaChartSeriesDataPointsNumberMismatch);
					}
					base.HAxis = area.GetAxis(AxisName.X, series.XAxisType, series.XSubAxisName);
					base.VAxis = area.GetAxis(AxisName.Y, series.YAxisType, series.YSubAxisName);
					base.hAxisMin = base.HAxis.ViewMinimum;
					base.hAxisMax = base.HAxis.ViewMaximum;
					base.vAxisMin = base.VAxis.ViewMinimum;
					base.vAxisMax = base.VAxis.ViewMaximum;
					this.axisPos.X = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
					this.axisPos.Y = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
					base.axisPos = graph.GetAbsolutePoint(base.axisPos);
					if (list2 == null)
					{
						list2 = new ArrayList(series.Points.Count);
					}
					else
					{
						list = list2;
						list2 = new ArrayList(series.Points.Count);
					}
					if (!selection)
					{
						common.Chart.CallOnPrePaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
					}
					int pointIndex = 0;
					float y = this.axisPos.Y;
					float x = this.axisPos.Y;
					PointF empty = PointF.Empty;
					PointF absolutePoint = PointF.Empty;
					foreach (DataPoint point in series.Points)
					{
						point.positionRel = new PointF(float.NaN, float.NaN);
						double logValue = point.IsEmpty ? 0.0 : this.GetYValue(common, area, series, point, pointIndex, 0);
						double axisValue = flag ? (pointIndex + 1.0) : point.XValue;
						if ((list != null) && (pointIndex < list.Count))
						{
							logValue += (double)list[pointIndex];
						}
						list2.Insert(pointIndex, logValue);
						float position = (float)base.VAxis.GetPosition(logValue);
						float num8 = (float)base.HAxis.GetPosition(axisValue);
						point.positionRel = new PointF(num8, position);
						logValue = base.VAxis.GetLogValue(logValue);
						axisValue = base.HAxis.GetLogValue(axisValue);
						if (empty == PointF.Empty)
						{
							empty.X = num8;
							empty.Y = position;
							if ((list != null) && (pointIndex < list.Count))
							{
								y = (float)base.VAxis.GetPosition((double)list[pointIndex]);
								y = graph.GetAbsolutePoint(new PointF(y, y)).Y;
							}
							empty = graph.GetAbsolutePoint(empty);
							pointIndex++;
							continue;
						}
						absolutePoint.X = num8;
						absolutePoint.Y = position;
						if ((list != null) && (pointIndex < list.Count))
						{
							x = (float)base.VAxis.GetPosition((double)list[pointIndex]);
							x = graph.GetAbsolutePoint(new PointF(x, x)).Y;
						}
						absolutePoint = graph.GetAbsolutePoint(absolutePoint);
						empty.X = (float)Math.Round((double)empty.X);
						absolutePoint.X = (float)Math.Round((double)absolutePoint.X);
						using (GraphicsPath path = new GraphicsPath())
						{
							path.AddLine(empty.X, empty.Y, absolutePoint.X, absolutePoint.Y);
							path.AddLine(absolutePoint.X, absolutePoint.Y, absolutePoint.X, x);
							path.AddLine(absolutePoint.X, x, empty.X, y);
							path.AddLine(empty.X, y, empty.X, empty.Y);
							if (common.ProcessModePaint)
							{
								double num9 = flag ? ((double)pointIndex) : series.Points[pointIndex - 1].XValue;
								if (((axisValue <= base.hAxisMin) && (num9 <= base.hAxisMin)) || ((axisValue >= base.hAxisMax) && (num9 >= base.hAxisMax)))
								{
									empty = absolutePoint;
									y = x;
									pointIndex++;
									continue;
								}
								Brush brush = null;
								if (point.BackHatchStyle != ChartHatchStyle.None)
								{
									brush = graph.GetHatchBrush(point.BackHatchStyle, point.Color, point.BackSecondaryColor);
								}
								else if (point.BackGradientStyle != GradientStyle.None)
								{
									base.gradientFill = true;
									base.Series = point.series;
								}
								else if (((point.BackImage.Length > 0) && (point.BackImageWrapMode != ChartImageWrapMode.Unscaled)) && (point.BackImageWrapMode != ChartImageWrapMode.Scaled))
								{
									brush = graph.GetTextureBrush(point.BackImage, point.BackImageTransparentColor, point.BackImageWrapMode, point.Color);
								}
								else if (point.IsEmpty && (point.Color == Color.Empty))
								{
									brush = new SolidBrush(series.Color);
								}
								else
								{
									brush = new SolidBrush(point.Color);
								}
								if ((point.BorderColor != Color.Empty) && (point.BorderWidth > 0))
								{
									flag2 = true;
								}
								if ((point.Label.Length > 0) || point.IsValueShownAsLabel)
								{
									flag3 = true;
								}
								if (!base.gradientFill)
								{
									graph.StartHotRegion(point);
									SmoothingMode smoothingMode = graph.SmoothingMode;
									graph.SmoothingMode = SmoothingMode.None;
									graph.FillPath(brush, path);
									graph.SmoothingMode = smoothingMode;
									Pen pen = new Pen(brush, 1f);
									if ((empty.X != absolutePoint.X) && (empty.Y != absolutePoint.Y))
									{
										graph.DrawLine(pen, empty.X, empty.Y, absolutePoint.X, absolutePoint.Y);
									}
									if ((empty.X != absolutePoint.X) && (x != y))
									{
										graph.DrawLine(pen, absolutePoint.X, x, empty.X, y);
									}
									graph.EndHotRegion();
								}
								if (base.areaPath == null)
								{
									base.areaPath = new GraphicsPath();
								}
								base.areaPath.AddLine(empty.X, empty.Y, absolutePoint.X, absolutePoint.Y);
								this.areaBottomPath.AddLine(empty.X, y, absolutePoint.X, x);
								if (brush != null)
								{
									brush.Dispose();
								}
							}
							if (common.ProcessModeRegions)
							{
								PointF relativePoint = PointF.Empty;
								float[] coord = new float[path.PointCount * 2];
								PointF[] pathPoints = path.PathPoints;
								for (int i = 0; i < path.PointCount; i++)
								{
									relativePoint = graph.GetRelativePoint(pathPoints[i]);
									coord[2 * i] = relativePoint.X;
									coord[(2 * i) + 1] = relativePoint.Y;
								}
								common.HotRegionsList.AddHotRegion(path, false, coord, point, series.Name, pointIndex);
								if (((point.BorderWidth > 1) && (point.BorderDashStyle != ChartDashStyle.NotSet)) && (point.BorderColor != Color.Empty))
								{
									using (GraphicsPath path2 = new GraphicsPath())
									{
										try
										{
											path2.AddLine(empty.X, empty.Y, absolutePoint.X, absolutePoint.Y);
											path2.Widen(new Pen(point.Color, (float)(point.BorderWidth + 2)));
										}
										catch (OutOfMemoryException)
										{
										}
										catch (ArgumentException)
										{
										}
										relativePoint = PointF.Empty;
										coord = new float[path2.PointCount * 2];
										for (int j = 0; j < path2.PointCount; j++)
										{
											relativePoint = graph.GetRelativePoint(path2.PathPoints[j]);
											coord[2 * j] = relativePoint.X;
											coord[(2 * j) + 1] = relativePoint.Y;
										}
										common.HotRegionsList.AddHotRegion(path2, false, coord, point, series.Name, pointIndex);
									}
								}
							}
						}
						empty = absolutePoint;
						y = x;
						pointIndex++;
					}
					if (base.gradientFill && (base.areaPath != null))
					{
						using (GraphicsPath path3 = new GraphicsPath())
						{
							path3.AddPath(base.areaPath, true);
							this.areaBottomPath.Reverse();
							path3.AddPath(this.areaBottomPath, true);
							using (Brush brush2 = graph.GetGradientBrush(path3.GetBounds(), base.Series.Color, base.Series.BackSecondaryColor, base.Series.BackGradientStyle))
							{
								graph.FillPath(brush2, path3);
							}
						}
						base.areaPath.Dispose();
						base.areaPath = null;
						base.gradientFill = false;
					}
					this.areaBottomPath.Reset();
					if (!selection)
					{
						common.Chart.CallOnPostPaint(new ChartPaintEventArgs(series, graph, common, area.PlotAreaPosition));
					}
				}
				if (flag2)
				{
					list = null;
					list2 = null;
					foreach (Series series2 in common.DataManager.Series)
					{
						if (((string.Compare(series2.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0) && (series2.ChartArea == area.Name)) && series2.IsVisible())
						{
							base.HAxis = area.GetAxis(AxisName.X, series2.XAxisType, series2.XSubAxisName);
							base.VAxis = area.GetAxis(AxisName.Y, series2.YAxisType, series2.YSubAxisName);
							this.axisPos.X = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
							this.axisPos.Y = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
							base.axisPos = graph.GetAbsolutePoint(base.axisPos);
							if (list2 == null)
							{
								list2 = new ArrayList(series2.Points.Count);
							}
							else
							{
								list = list2;
								list2 = new ArrayList(series2.Points.Count);
							}
							int num12 = 0;
							float num13 = this.axisPos.Y;
							float num14 = this.axisPos.Y;
							PointF tf4 = PointF.Empty;
							PointF tf5 = PointF.Empty;
							foreach (DataPoint point2 in series2.Points)
							{
								double num15 = point2.IsEmpty ? 0.0 : this.GetYValue(common, area, series2, point2, num12, 0);
								double num16 = flag ? (num12 + 1.0) : point2.XValue;
								if ((list != null) && (num12 < list.Count))
								{
									num15 += (double)list[num12];
								}
								list2.Insert(num12, num15);
								float num17 = (float)base.VAxis.GetPosition(num15);
								float num18 = (float)base.HAxis.GetPosition(num16);
								if (tf4 == PointF.Empty)
								{
									tf4.X = num18;
									tf4.Y = num17;
									if ((list != null) && (num12 < list.Count))
									{
										num13 = (float)base.VAxis.GetPosition((double)list[num12]);
										num13 = graph.GetAbsolutePoint(new PointF(num13, num13)).Y;
									}
									tf4 = graph.GetAbsolutePoint(tf4);
									tf5 = tf4;
									num14 = num13;
								}
								else
								{
									tf5.X = num18;
									tf5.Y = num17;
									if ((list != null) && (num12 < list.Count))
									{
										num14 = (float)base.VAxis.GetPosition((double)list[num12]);
										num14 = graph.GetAbsolutePoint(new PointF(num14, num14)).Y;
									}
									tf5 = graph.GetAbsolutePoint(tf5);
								}
								if (num12 != 0)
								{
									tf4.X = (float)Math.Round((double)tf4.X);
									tf5.X = (float)Math.Round((double)tf5.X);
									graph.DrawLineRel(point2.BorderColor, point2.BorderWidth, point2.BorderDashStyle, graph.GetRelativePoint(tf4), graph.GetRelativePoint(tf5), point2.series.ShadowColor, point2.series.ShadowOffset);
								}
								tf4 = tf5;
								num13 = num14;
								num12++;
							}
						}
					}
				}
				if (flag3)
				{
					list = null;
					list2 = null;
					foreach (Series series3 in common.DataManager.Series)
					{
						if (((string.Compare(series3.ChartTypeName, this.Name, StringComparison.OrdinalIgnoreCase) == 0) && (series3.ChartArea == area.Name)) && series3.IsVisible())
						{
							base.HAxis = area.GetAxis(AxisName.X, series3.XAxisType, series3.XSubAxisName);
							base.VAxis = area.GetAxis(AxisName.Y, series3.YAxisType, series3.YSubAxisName);
							this.axisPos.X = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
							this.axisPos.Y = (float)base.VAxis.GetPosition(base.VAxis.Crossing);
							base.axisPos = graph.GetAbsolutePoint(base.axisPos);
							if (list2 == null)
							{
								list2 = new ArrayList(series3.Points.Count);
							}
							else
							{
								list = list2;
								list2 = new ArrayList(series3.Points.Count);
							}
							int num19 = 0;
							float num20 = this.axisPos.Y;
							float num21 = this.axisPos.Y;
							PointF tf6 = PointF.Empty;
							PointF tf7 = PointF.Empty;
							foreach (DataPoint point3 in series3.Points)
							{
								double num22 = point3.IsEmpty ? 0.0 : this.GetYValue(common, area, series3, point3, num19, 0);
								double num23 = flag ? (num19 + 1.0) : point3.XValue;
								if ((list != null) && (num19 < list.Count))
								{
									num22 += (double)list[num19];
								}
								list2.Insert(num19, num22);
								float num24 = (float)base.VAxis.GetPosition(num22);
								float num25 = (float)base.HAxis.GetPosition(num23);
								if (tf6 == PointF.Empty)
								{
									tf6.X = num25;
									tf6.Y = num24;
									if ((list != null) && (num19 < list.Count))
									{
										num20 = (float)base.VAxis.GetPosition((double)list[num19]);
										num20 = graph.GetAbsolutePoint(new PointF(num20, num20)).Y;
									}
									tf7 = graph.GetAbsolutePoint(tf6);
									num21 = num20;
								}
								else
								{
									tf7.X = num25;
									tf7.Y = num24;
									if ((list != null) && (num19 < list.Count))
									{
										num21 = (float)base.VAxis.GetPosition((double)list[num19]);
										num21 = graph.GetAbsolutePoint(new PointF(num21, num21)).Y;
									}
									tf7 = graph.GetAbsolutePoint(tf7);
								}
								if (!point3.IsEmpty && ((series3.IsValueShownAsLabel || point3.IsValueShownAsLabel) || (point3.Label.Length > 0)))
								{
									using (StringFormat format = new StringFormat())
									{
										string str;
										format.Alignment = StringAlignment.Center;
										format.LineAlignment = StringAlignment.Center;
										if (point3.Label.Length == 0)
										{
											double num26 = this.GetYValue(common, area, series3, point3, num19, 0);
											if (this.hundredPercentStacked && (point3.LabelFormat.Length == 0))
											{
												num26 = Math.Round(num26, 2);
											}
											str = ValueConverter.FormatValue(series3.Chart, point3, point3.Tag, num26, point3.LabelFormat, series3.YValueType, ChartElementType.DataPoint);
										}
										else
										{
											str = point3.ReplaceKeywords(point3.Label);
										}
										Region clip = graph.Clip;
										graph.Clip = new Region();
										PointF tf8 = PointF.Empty;
										tf8.X = tf7.X;
										tf8.Y = tf7.Y - ((tf7.Y - num21) / 2f);
										tf8 = graph.GetRelativePoint(tf8);
										SizeF relativeSize = graph.GetRelativeSize(graph.MeasureString(str, point3.Font, new SizeF(1000f, 1000f), StringFormat.GenericTypographic));
										RectangleF backPosition = RectangleF.Empty;
										SizeF ef3 = new SizeF(relativeSize.Width, relativeSize.Height);
										ef3.Height += relativeSize.Height / 8f;
										ef3.Width += ef3.Width / ((float)str.Length);
										backPosition = new RectangleF(tf8.X - (ef3.Width / 2f), (tf8.Y - (ef3.Height / 2f)) - (relativeSize.Height / 10f), ef3.Width, ef3.Height);
										using (Brush brush3 = new SolidBrush(point3.LabelForeColor))
										{
											graph.DrawPointLabelStringRel(common, str, point3.Font, brush3, tf8, format, point3.LabelAngle, backPosition, point3.LabelBackColor, point3.LabelBorderColor, point3.LabelBorderWidth, point3.LabelBorderDashStyle, series3, point3, num19);
										}
										graph.Clip = clip;
									}
								}
								tf6 = tf7;
								num20 = num21;
								num19++;
							}
						}
					}
				}
			}
		}

		public override string Name
		{
			get
			{
				return "StackedArea";
			}
		}

		public override bool Stacked
		{
			get
			{
				return true;
			}
		}
	}
}

